﻿using System;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication2._8_加解密
{
    public partial class md5 : Form
    {
        public md5()
        {
            InitializeComponent();
        }

        // 要添加上面的引用
        public string md51(string str)
        {
            MD5 m = new MD5CryptoServiceProvider();
            byte[] s = m.ComputeHash(UnicodeEncoding.UTF8.GetBytes(str));
            return BitConverter.ToString(s);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string strIn = this.textBox1.Text;

            if (strIn.Trim() == "")
            {
                MessageBox.Show("请输入");
            }

            string strOut = md51(strIn);

            this.textBox2.Text = strOut.Replace("-", "").ToLower();
        }

        private void md5_Load(object sender, EventArgs e)
        {
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //md5没有解密
        }

        private void md5_Load_1(object sender, EventArgs e)
        {
        }
    }
}